import request from '/@/utils/request';

/**
 * 以下为模拟接口地址，gitee 的不通，就换自己的真实接口地址
 *
 * （不建议写成 request.post(xxx)，因为这样 post 时，无法 params 与 data 同时传参）
 *
 * 后端控制菜单模拟json，路径在 https://gitee.com/lyt-top/vue-next-admin-images/tree/master/menu
 * 后端控制路由，isRequestRoutes 为 true，则开启后端控制路由
 * @method getNavigation 获取后端动态路由菜单(admin)
 */
export function useSystemApi() {
	return {
		getNavigationAdmin: (params?: object) => {
			return request({
				url: '/api/Permission/GetNavigationBar',
				method: 'get',
				params,
			});
		},
		getNavigationUser: (params?: object) => {
			return request({
				url: '/api/Permission/GetNavigationBar',
				method: 'get',
				params,
			});
		}
	};
}


// 接口模块管理
export const getModuleListPage = (params: any) => {
    return request(
        {
            url: '/api/Module/Get',
            method: 'get',
            params,
        }
    )
};
export const removeModule = (params: any) => {
    return request(
        {
            url: '/api/Module/Delete',
            method: 'delete',
            params: params
        }
    )
};
export const editModule = (params: any) => {
    return request(
        {
            url: '/api/Module/Put',
            method: 'put',
            data: params
        }
    )
};
export const addModule = (params: any) => {
    return request(
        {
            url: '/api/Module/Post',
            method: 'post',
            data: params
        }
    )
};


// 菜单模块管理
export const getPermissionListPage = (params: any) => {
    return request(
        {
            url: '/api/Permission/Get',
            method: 'get',
           params,
        }
    )
};
export const getPermissionTreeTable = (params: any) => {
    return request(
        {
            url: '/api/Permission/GetTreeTable',
            method: 'get',
           params,
        }
    )
};
export const migratePermissionTable = (params: any) => {
    return request(
        {
            url: '/api/Permission/MigratePermissionTable',
            method: 'get',
           params,
        }
    )
};
export const removePermission = (params: any) => {
    return request(
        {
            url: '/api/Permission/Delete',
            method: 'delete',
            params: params
        }
    )
};

export const editPermission = (params: any) => {
    return request(
        {
            url: '/api/Permission/Post',
            method: 'post',
            data: params
        }
    )
};
export const getPermissionTree = (params: any) => {
    return request(
        {
            url: '/api/Permission/GetPermissionTree',
            method: 'get',
           params,
        }
    )
};
export const getPermissionIds = (params: any) => {
    return request(
        {
            url: '/api/Permission/GetPermissionIdByRoleId',
            method: 'get',
           params,
        }
    )
};

export const addRolePermission = (params: any) => {
    return request(
        {
            url: '/api/Permission/Assign',
            method: 'post',
            data: params
        }
    )
};
export const getNavigationBar = (params: any) => {
    return request(
        {
            url: '/api/Permission/GetNavigationBar',
            method: 'get',
           params,
        }
    )
};


// 部门模块管理
export const getDepartmentListPage = (params: any) => {
    return request(
        {
            url: '/api/Department/Get',
            method: 'get',
           params,
        }
    )
};
export const getDepartmentTreeTable = (params: any) => {
    return request(
        {
            url: '/api/Department/GetTreeTable',
            method: 'get',
           params,
        }
    )
};

export const removeDepartment = (params: any) => {
    return request(
        {
            url: '/api/Department/Delete',
            method: 'delete',
            params: params
        }
    )
};
export const editDepartment = (params: any) => {
    return request(
        {
            url: '/api/Department/Put',
            method: 'put',
            data: params
        }
    )
};
export const addDepartment = (params: any) => {
    return request(
        {
            url: '/api/Department/Post',
            method: 'post',
            data: params
        }
    )
};
export const getDepartmentTree = (params: any) => {
    return request(
        {
            url: '/api/Department/GetDepartmentTree',
            method: 'get',
           params,
        }
    )
};